package com.simple.study.controller.menu;

import com.simple.study.base.controller.BaseController;
import com.simple.study.entity.ShopResult;
import com.simple.study.pojo.Permission;
import com.simple.study.service.MenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName MenuController
 * @Author SimpleTree
 **/
@RestController
public class MenuController extends BaseController {

    @Autowired
    private MenusService menusService;

    /**
     * type=list，获取显示权限，
     * type=tree，树形展示
     * @return
     */
    @GetMapping("/rights/list")
    public ShopResult getMenusListByList() {
        List<Permission> menusList = menusService.getMenusList();
        return shopSuccess(200, "获取权限列表成功", menusList);
    }

    @GetMapping("/rights/tree")
    public ShopResult getMenusListByTree() {
        List<Permission> menusTree = menusService.getMenusTree();
        return shopSuccess(200, "获取权限列表成功", menusTree);
    }


    @GetMapping("/menus")
    public ShopResult getMenusList() {

        List<Permission> menusList = menusService.getMenus();

        return shopSuccess(200, "获取菜单列表成功", menusList);
    }
}
